package Test03;

import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.net.Socket;

import lesson16.User;

public class LoginThread extends Thread {
	Socket socket;
	
	public LoginThread(Socket socket) {
		this.socket = socket;
	}

	@Override
	public void run() {
		try {
		InputStream is=socket.getInputStream();
		OutputStream os=socket.getOutputStream();
		
		ObjectInputStream ois=new ObjectInputStream(is);
		User user=(User) ois.readObject();
		System.out.println("我是服务器登陆信息为："+user.toString());
		
		String reply="我是服务器，欢迎登陆！";
		os.write(reply.getBytes());
		
		is.close();
		os.close();
		ois.close();
		socket.close();
				
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

}
